import uiautomation
import pyautogui
class menzhenhushizhan():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()
        zhidingyi = his.CustomControl(AutomationId='nurseWorkstation', ClassName='NurseWorkstation')  #自定义窗口
        menzhenhaoshurukuang = zhidingyi.EditControl(AutomationId='txtMZH', ClassName='TextBox') # 门诊号输入框
        xingmingshurukuang = zhidingyi.EditControl(ClassName='TextBox',foundIndex=2) #姓名输入框
        weizhixing = zhidingyi.RadioButtonControl(ClassName='RadioButton', Name='未执行') #未执行按钮
        yizhixing = zhidingyi.RadioButtonControl(ClassName='RadioButton', Name='已执行') #已执行按钮
        benkeshi = zhidingyi.RadioButtonControl(ClassName='RadioButton', Name='本科室') #本科室按钮
        quanbukeshi = zhidingyi.RadioButtonControl(ClassName='RadioButton', Name='全部科室') #全部科室按钮
        chaxun = zhidingyi.ButtonControl(AutomationId='btnSearch', ClassName='Button',Name='查询') #查询按钮
        zhixing = zhidingyi.ButtonControl(AutomationId='btnExecute', ClassName='Button', Name='执行') #执行按钮
        pingtie = zhidingyi.ButtonControl(AutomationId='btnPingTie', ClassName='Button', Name='瓶贴') #瓶贴按钮
        shuyedan = zhidingyi.ButtonControl(AutomationId='btnShuYeDan', ClassName='Button', Name='输液单') #输液单按钮
        zhixingdan = zhidingyi.ButtonControl(AutomationId='btnZhiXinDan', ClassName='Button', Name='执行单')  #执行单按钮
        feiyongxinxi = zhidingyi.ButtonControl(AutomationId='btnFeiYongXinXi', ClassName='Button', Name='费用信息') #费用信息按钮
        dianzhipingzheng = zhidingyi.ButtonControl(ClassName='Button', Name='电子凭证') #电子凭证按钮

        #患者数据网格
        shujuwangge1 = his.DataGridControl(AutomationId='dgPatient',ClassName='DataGrid')
        huanzheshuju1 = shujuwangge1.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.MZPatientInfoModel',foundIndex=1)
        huanzheshuju2 = shujuwangge1.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.MZPatientInfoModel',foundIndex=2)
        huanzheshuju3 = shujuwangge1.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.MZPatientInfoModel',foundIndex=3)
        huanzheshuju4 = shujuwangge1.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.MZPatientInfoModel',foundIndex=4)
        huanzheshuju5 = shujuwangge1.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.MZPatientInfoModel',foundIndex=5)

        #选项卡
        shuyedanxuanxiangka = his.TabItemControl(AutomationId='tblShuYeDan', ClassName='TabItem', Name='输液单')
        zhushedanxuanxiangka = his.TabItemControl(AutomationId='tblZhuSheDan', ClassName='TabItem', Name='注射单')
        shimingxuanxiangka = his.TabItemControl(AutomationId='tblShiMin', ClassName='TabItem', Name='试敏')
        xiyangdanxuanxiangka = his.TabItemControl(AutomationId='tbXiYang', ClassName='TabItem', Name='吸氧单')
        SOAPxuanxiangka = his.TabItemControl(ClassName='TabItem', Name='SOAP')

#标头
        quanxuanbiaotou = his.DataGridControl(AutomationId='dgDetail',ClassName='DataGrid').HeaderControl(AutomationId='PART_ColumnHeadersPresenter',ClassName='DataGridColumnHeadersPresenter').HeaderItemControl(ClassName='DataGridColumnHeader')


        #数据项
        yaopinshuju1 = his.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel',foundIndex=1)
        yaopinshuju2 = his.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel',foundIndex=2)
        yaopinshuju3 = his.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel',foundIndex=3)
        yaopinshuju4 = his.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel',foundIndex=4)
        yaopinshuju5 = his.DataItemControl(ClassName='DataGridRow',Name='Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel',foundIndex=5)

        #数据标头
        shuju1biaotou = yaopinshuju1.CustomControl(ClassName='DataGridCell',Name='项: Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel，列显示索引: 0')
        shuju2biaotou = yaopinshuju1.CustomControl(ClassName='DataGridCell',Name='项: Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel，列显示索引: 0')
        shuju3biaotou = yaopinshuju1.CustomControl(ClassName='DataGridCell',Name='项: Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel，列显示索引: 0')
        shuju4biaotou = yaopinshuju1.CustomControl(ClassName='DataGridCell',Name='项: Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel，列显示索引: 0')
        shuju5biaotou = yaopinshuju1.CustomControl(ClassName='DataGridCell',Name='项: Yuanbo.ChssClient.OutFeeManager.Model.Nurse.SkinTestDetailModel，列显示索引: 0')


        #试敏结果
        shimingjieguo = his.WindowControl(ClassName='Window',Name='试敏结果')
        shimingjieguo_queding = shimingjieguo.ButtonControl(AutomationId='btnSave',ClassName='Button',Name='确定')
        shimingjieguo_quxiao = shimingjieguo.ButtonControl(AutomationId='btnCancel',ClassName='Button',Name='取消')

        #修改试敏结果
        xiugaishiming = his.ButtonControl(ClassName='Button', Name='修改')
        xiugaishimingjieguo = his.WindowControl(ClassName='Window',Name='修改试敏结果')
        xiugaishimingjieguo_zhuhekuang =  xiugaishimingjieguo.ComboBoxControl(AutomationId='cbxSMJG',ClassName='ComboBox')
        xiugaishiminjieguo1 = xiugaishimingjieguo_zhuhekuang.ListItemControl(ClassName='ListBoxItem',Name='-')
        xiugaishiminjieguo2 = xiugaishimingjieguo_zhuhekuang.ListItemControl(ClassName='ListBoxItem', Name='+')
        xiugaishiminjieguo3 = xiugaishimingjieguo_zhuhekuang.ListItemControl(ClassName='ListBoxItem', Name='++')
        xiugaishiminjieguo4 = xiugaishimingjieguo_zhuhekuang.ListItemControl(ClassName='ListBoxItem', Name='+++')
        xiugaishiminjieguo5 = xiugaishimingjieguo_zhuhekuang.ListItemControl(ClassName='ListBoxItem', Name='±')

        xiugaishimingjieguo_queding = xiugaishimingjieguo.ButtonControl(AutomationId='btnSave', ClassName='Button', Name='确定')
        xiugaishimingjieguo_quxiao = xiugaishimingjieguo.ButtonControl(AutomationId='btnCancel', ClassName='Button', Name='取消')

#输入门诊号
        def input_mzh(self,menzhenghao):
                self.menzhenhaoshurukuang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.press('back')
                self.menzhenhaoshurukuang.SendKeys(menzhenghao)

#输入姓名
        def input_xm(self,name):
                self.xingmingshurukuang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.press('back')
                self.xingmingshurukuang.SendKeys(name)

#点击未执行按钮
        def click_wzx_btn(self):
                self.weizhixing.Click()

#点击已执行按钮
        def click_yzx_btn(self):
                self.yizhixing.Click()

#点击本科室按钮
        def click_bks_btn(self):
                self.benkeshi.Click()

#点击全部科室按钮
        def click_qbks_btn(self):
                self.quanbukeshi.Click()

#点击查询按钮
        def click_cx_btn(self):
                self.chaxun.Click()

#点击执行按钮
        def click_zx_btn(self):
                self.zhixing.Click()

#点击瓶贴按钮
        def click_pt_btn(self):
                self.pingtie.Click()

#点击输液单按钮
        def click_syd_btn(self):
                self.shuyedan.Click()

#点击执行单按钮
        def click_zxd_btn(self):
                self.zhixingdan.Click()

#点击费用信息按钮
        def click_fyxx_btn(self):
                self.feiyongxinxi.Click()

#点击电子凭证按钮
        def click_dzpz_btn(self):
                self.dianzhipingzheng.Click()

#双击患者数据
        #双击患者信息1
        def click_hzsj1(self):
                self.huanzheshuju1.DoubleClick()
        # 双击患者信息2
        def click_hzsj2(self):
                self.huanzheshuju2.DoubleClick()
        #双击患者信息3
        def click_hzsj3(self):
                self.huanzheshuju3.DoubleClick()
        #双击患者信息4
        def click_hzsj4(self):
                self.huanzheshuju4.DoubleClick()
        #双击患者信息5
        def click_hzsj5(self):
                self.huanzheshuju5.DoubleClick()

#点击选项卡
        #点击输液单选项卡
        def click_syd_xxk(self):
                self.shuyedanxuanxiangka.Click()

        #点击注射单选项卡
        def click_zsd_xxk(self):
                self.zhushedanxuanxiangka.Click()

        #点击试敏选项卡
        def click_sm_xxk(self):
                self.shimingxuanxiangka.Click()

        #点击吸氧单选项卡
        def click_xyd_xxk(self):
                self.xiyangdanxuanxiangka.Click()

        #点击SOAP选项卡
        def click_soap_xxk(self):
                self.SOAPxuanxiangka.Click()


#标头
        #点击全选标头
        def click_qxbt_btn(self):
                self.quanxuanbiaotou.Click()

        #点击数据1标头
        def click_sj1_btn(self):
                self.shuju1biaotou.Click()

        #点击数据2标头
        def click_sj2_btn(self):
                self.shuju2biaotou.Click()

        #点击数据3标头
        def click_sj3_btn(self):
                self.shuju3biaotou.Click()

        #点击数据4标头
        def click_sj4_btn(self):
                self.shuju4biaotou.Click()

        #点击数据5标头
        def click_sj5_btn(self):
                self.shuju5biaotou.Click()

#试敏

        #点击试敏确定按钮
        def click_smqd_btn(self):
                self.shimingjieguo_queding.Click()
        #点击试敏取消按钮
        def click_smqx_btn(self):
                self.shimingjieguo_quxiao.Click()
        #点击试敏修改按钮
        def click_smxg_btn(self):
                self.xiugaishiming.Click()

        #点击试敏结果1
        def click_smjg1(self):
                self.xiugaishimingjieguo_zhuhekuang.Click()
                self.xiugaishiminjieguo1.Click()

        #点击试敏结果2
        def click_smjg2(self):
                self.xiugaishimingjieguo_zhuhekuang.Click()
                self.xiugaishiminjieguo2.Click()

        #点击试敏结果3
        def click_smjg3(self):
                self.xiugaishimingjieguo_zhuhekuang.Click()
                self.xiugaishiminjieguo3.Click()

        #点击试敏结果4
        def click_smjg4(self):
                self.xiugaishimingjieguo_zhuhekuang.Click()
                self.xiugaishiminjieguo4.Click()

        #点击试敏结果5
        def click_smjg5(self):
                self.xiugaishimingjieguo_zhuhekuang.Click()
                self.xiugaishiminjieguo5.Click()

        #点击修改试敏结果确定按钮
        def click_xgsmqd_btn(self):
                self.xiugaishimingjieguo_queding.Click()

        #点击修改试敏结果取消按钮
        def click_xgsmqx_btn(self):
                self.xiugaishimingjieguo_quxiao.Click()

















